package com.example.test;

import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;

import net.duohuo.dhroid.activity.BaseActivity;
import net.duohuo.dhroid.adapter.NetBeanAdapter;
import net.duohuo.dhroid.net.model.JSONObjectN;
import net.duohuo.dhroid.util.MapUtil;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.example.test.api.API;
import com.example.test.views.RefreshListViewAndMore;

public class ListActivity extends BaseActivity {

	RefreshListViewAndMore ListV;

	//
	NetBeanAdapter<HashMap<String, Object>> adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list);
		ListV = (RefreshListViewAndMore) findViewById(R.id.my_listview);
		initAdapter();
	}

	private void initAdapter() {
		adapter = new NetBeanAdapter<HashMap<String, Object>>(
				new API().marketGoodList, ListActivity.this, R.layout.item_list);
		adapter.fromWhat("list");
		adapter.addparam("user_id", "7");
		adapter.addparam("communityid", "1");
		adapter.addparam("catid", "37");
		adapter.addField("title", R.id.name);
		ListV.setAdapter(adapter);
		ListV.getContentView().setOnItemClickListener(
				new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						
						HashMap<String, Object> map = adapter
								.getTItem(position);
						System.out.println("数据........."
								+ MapUtil.getString(map,"price"));

					}
				});
	}

}
